package geowiki.vis;

import geowiki.data.Place;
import processing.core.PApplet;

/**
 * A PlaceMarker represents a place visually.
 */
public class PlaceMarker {

	private final PApplet p;

	public String name;
	public float lat;
	public float lng;
	
	public int red = 255;
	public int green = 0;
	public int blue = 0;

	float x;
	float y;

        int offset=0;

	public PlaceMarker(PApplet p, String name, float lat, float lng) {
		this.p = p;

		this.name = name;
		this.lat = lat;
		this.lng = lng;
		
		// Equirectangular projection
		this.x = PApplet.map(lng, -180, 180, 0, p.width);
		this.y = PApplet.map(lat, 90, -90, offset, p.height);
	}

	public PlaceMarker(PApplet p, Place place) {
		this(p, place.name, place.lat, place.lng);
	}

        public PlaceMarker(PApplet p, Place place, int offset) {
		this(p, place.name, place.lat, place.lng);
                this.offset=offset;
                this.x = PApplet.map(lng, -180, 180, 0, p.width);
		this.y = PApplet.map(lat, 90, -90, offset, p.height);
	}
	
	public PlaceMarker(PApplet p, Place place, int red, int green, int blue) {
		this(p, place.name, place.lat, place.lng);
		
		this.red=red;
		this.green=green;
		this.blue=blue;
	}

	public void display() {
		p.noStroke();
		p.fill(red, green, blue, 50);
		p.ellipse(x, y, 15, 15);
		p.fill(red, green, blue, 200);
		p.ellipse(x, y, 5, 5);
	}

        public void display(int color) {
		p.noStroke();
		p.fill(color, 50);
		p.ellipse(x, y, 15, 15);
		p.fill(color, 200);
		p.ellipse(x, y, 5, 5);
	}
	
	public void displaySmall() {
		p.noStroke();
		p.fill(red, green, blue, 50);
		p.ellipse(x, y, 5, 5);
	}


        public void displaySmall(int color) {
		p.noStroke();
		p.fill(color, 50);
		p.ellipse(x, y, 5, 5);
	}

         public void displayVerySmall(int color) {
		p.noStroke();
		p.fill(color, 25);
		p.ellipse(x, y, 2, 2);
                p.fill(color, 25);
		p.ellipse(x, y, 4, 4);
	}


        public void displayVeryVerySmall(int color) {
		p.noStroke();
		
                p.fill(color, 10);
		p.ellipse(x, y, 2, 2);
                p.fill(color, 5);
		p.ellipse(x, y, 3, 3);
                p.fill(color, 15);
		p.ellipse(x, y, 1, 1);
	}

         public void displayVerySmall3D(int color) {
		p.noStroke();
		p.fill(color, 25);
		p.ellipse(x, y, 2, 2);
                p.fill(color, 25);
		p.ellipse(x, y, 4, 4);
	}



	
	public float getX() {
		return x;
	}
	
	public float getY() {
		return y;
	}
	

}
